Greatest Common Divisor From Factorisation

Theorem

Given integers a=p1α1p2α2pnαn and b=p1β1p2β2pnβn written in their prime factorisations, the greatest common divisor of a and b is given by

gcd(a,b)=p1min{α1,β1}p2min{α2,β2}pnmin{αn,βn}.

Note that as written above, we use the same set of primes in the factorisation for each a and b. This is just for notational simplicity. Think of {p1,,pn} as the set of all primes which divide either a or b, and the powers αi or βi may be 0 as necessary.

The idea here is very simple, choosing a power bigger than either αi or βi for pi will result in the result not being a common divisor, however choosing anything smaller than both will not be as big as it can be. Hence we take the minimimum of the corresponding powers.

Proof

This follows from the expression of divisors from the unique factorisation.

That is, some integer m is a divisor of a and b if

m=p1γ1p2γ2pnγn

where 0γiαi,βi for all i{1,,n}. Since pi2 for each pi, maximising powers of each pi results in the greatest integer m. As such, to maintain the condition above, we choose γi=min{αi,βi} for each i.


Example

The greatest common divisor of a=8624=24×72×11 and b=415030=2×5×73×112 is

2×72×11.